import Vue from 'vue'
import Router from 'vue-router'
import Main from '@/views/admin/navigation.vue'

Vue.use(Router)

/***
 *  首页路由配置
 * @type {*[]}
 */
let home = [
    {
        path: '/',
        name: '重定向',
        redirect: '/login'
    }, {
        path: '/login',
        name: '登录',
        component: (resolve) => require(['./views/login.vue'], resolve)
    }]
/**
 * 后台管理也面默认首页
 * @type {{path: string, component, children: {path: string, name: string, component: (function(*=): *)}[]}[]}
 */
let adminHome = [
    // 后台默认首页
    {
        path: '/',
        component: Main,
        children: [
            {path: 'index', name: '后台管理首页', component: (resolve) => require(['./views/admin/index'], resolve)}
        ]
    }
]
/**
 *  权限管理相关路由
 * @type {{path: string, component, children: *[]}[]}
 */
let permission = [
    {
        path: '/core',
        component: Main,
        children: [
            {
                path: 'menuList',
                name: '菜单列表',
                component: (resolve) => require(['./views/core/menu/menuList'], resolve)
            },
            {
                path: 'addMenu',
                name: '添加菜单',
                component: (resolve) => require(['./views/core/menu/addMenu'], resolve)
            }, {
                path: 'serviceList',
                name: '服务管理',
                component: (resolve) => require(['./views/core/service/serviceList'], resolve)
            }, {
                path: 'addService',
                name: '添加服务',
                component: (resolve) => require(['./views/core/service/addService'], resolve)
            }, {
                path: 'permissionList',
                name: '权限列表',
                component: (resolve) => require(['./views/core/permission/permissionList'], resolve)
            }, {
                path: 'addPermission',
                name: '添加权限',
                component: (resolve) => require(['./views/core/permission/addPermission'], resolve)
            }, {
                path: 'roleList',
                name: '角色列表',
                component: (resolve) => require(['./views/core/role/roleList'], resolve)
            }, {
                path: 'addRole',
                name: '添加角色',
                component: (resolve) => require(['./views/core/role/addRole'], resolve)
            }, {
                path: 'userList',
                name: '用户管理',
                component: (resolve) => require(['./views/core/user/userList'], resolve)
            }, {
                path: 'addUser',
                name: '添加用户',
                component: (resolve) => require(['./views/core/user/addUser'], resolve)
            }, {
                path: 'editUser',
                name: '更新用户',
                component: (resolve) => require(['./views/core/user/editUser'], resolve)
            }, {
                path: 'updatePassword',
                name: '修改密码',
                component: (resolve) => require(['./views/core/user/updatePassword'], resolve)
            }, {
                path: 'resetPassword',
                name: '重置密码',
                component: (resolve) => require(['./views/core/user/resetPassword'], resolve)
            },
            {
                path: 'cronList',
                name: '任务管理',
                component: (resolve) => require(['./views/core/cron/cronList'], resolve)
            }, {
                path: 'addCron',
                name: '添加任务',
                component: (resolve) => require(['./views/core/cron/addCron'], resolve)
            }, {
                path: 'codeList',
                name: '字典管理',
                component: (resolve) => require(['./views/core/code/codeList'], resolve)
            }, {
                path: 'addCode',
                name: '添加字典',
                component: (resolve) => require(['./views/core/code/addCode'], resolve)
            }, {
                path: 'apiList',
                name: '接口列表',
                component: (resolve) => require(['./views/core/api/apiList'], resolve)
            },
            {
                path: 'addApi',
                name: '添加接口',
                component: (resolve) => require(['./views/core/api/addApi'], resolve)
            }


        ]
    }
]
// 用户基本信息管理
let userInfo = [{
    path: '/bs/userInfo',
    component: Main,
    children: [
        {
            path: 'userList',
            name: '用户管理',
            component: (resolve) => require(['./views/bs/userInfo/userList'], resolve)
        }, {
            path: 'userEdit',
            name: '用户信息',
            component: (resolve) => require(['./views/bs/userInfo/userEdit'], resolve)
        },
    ]
},]

/**
 * 全局路由定义
 */
export default new Router({
    routes: [
        ...home,
        ...adminHome,
        ...permission,
        ...userInfo,
    ]
})
